package org.practice.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.practice.dao.ShopDaoFactory;
import org.practice.dao.UserDao;

public class RegisterCheckEmailAction extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
//		Client Browser��Ajax�첽����Server RegisterCheckEmailAction
//		Ŀ������֤��email�Ƿ�ʹ����
		String email = request.getParameter("email");
//		RegisterForm rf=(RegisterForm)form;
//		String email=rf.getEmail();
		boolean flag = false;
		if (email != null) {
			UserDao userDao = ShopDaoFactory.createUserDao();
			flag = userDao.checkEmail(email);
		}
		response.setContentType("text/html;charset=utf-8");
		response.getWriter().write("{'value':" + flag + "}");
		
		return null;
	}
	
}
